package cn.dmp.tags

import org.apache.commons.lang.StringUtils
import org.apache.spark.sql.Row

/**
  * 广告标签和渠道标签
  * Created by Administrator on 2018/4/29.
  */
object Tags4AD extends Tags{
  override def makeTags(args: Any*): Map[String, Int] = {

    val row = args(0).asInstanceOf[Row]

    var tags=Map[String,Int]()
    val adST = row.getAs[Int]("adspacetype")
    val adSTN = row.getAs[String]("adspacetypename")

    //广告位类型和广告名称 并存入Map里
    if (adST < 10) tags += "LC0" + adST -> 1 else tags += "LC" + adST -> 1
    if (StringUtils.isNotEmpty(adSTN)) tags +="LN" + adSTN -> 1

    //渠道
    val adplat = row.getAs[Int]("adplatformproviderid")
    if (adplat > 0) tags += "CN" + adplat -> 1

    tags
  }
}
